<?php
/* 
 * Aclass_log
 * mysql 类
存储格式：
|time|ip|type|content|
 */
class Aclass_log{

	function  __construct() {
	}

	function write($content,$type='sys'){
		$content = '|'.Afun_get_time().'|'.Afun_get_ip().'|'.$type.'|'.$content."\n";
		$path = Acan_path_log.Acan_app_name.'/'.$type.date("/Y-m-d",time()).'.log';
		Afunc_file()->file_save($path,$content,'','a+');
	}
	function log_write($content,$type='sys'){
		$sql="INSERT INTO `".Acan_table_error_log."` (`appname`,`type`,`ip`,`datetime`,`data`) VALUES ('".Acan_app_name."','$type','".Afun_get_ip()."','".Afun_get_time()."','".addslashes($content)."')";
		return Afun_db()->adbs->exec($sql,0);
		/*$content = '|'.Afun_get_time().'|'.Afun_get_ip().'|'.$type.'|'.$content."\n";
		$path = Acan_path_log.Acan_app_name.'/'.$type.date("/Y-m-d",time()).'.log';
		Afunc_file()->file_save($path,$content,'','a+');*/
	}

	function mysql($content,$type='query',$times=0,$uid=0,$rs=''){
		$sql="INSERT INTO `".Acan_table_mysql_log."` (`appname`,`type`,`uid`,`datetime`,`sql`,`time`,`rs`) VALUES ('".Acan_app_name."','$type','$uid','".Afun_get_time()."','".addslashes($content)."','$times','$rs')";
		return Afun_db()->exec($sql,0);
		//$this->log_write($content,'mysql_'.$type);
	}

}

?>
